﻿using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using Microsoft.Commerce.Proxy.PaymentInstrumentService;

namespace TestWebApplication.CommercePaymentInstrument.APIs
{
    public class CommerceRemovePaymentInstrumentApi : CommercePaymentInstrumentApi
    {
        private RemovePaymentInstrumentInput input;
        private RemovePaymentInstrumentOutput output;

        private CallerInfo callerInfo;
        private string paymentMethodId;

        public CommerceRemovePaymentInstrumentApi(BasicHttpBinding binding, EndpointAddress address, X509Certificate2 clientCert, CallerInfo callerInfo, string paymentMethodId)
            : base(binding, address, clientCert)
        {
            this.callerInfo = callerInfo;
            this.paymentMethodId = paymentMethodId;
        }

        protected override AbstractResponse ExecuteInternal(PaymentInstrumentServiceChannel channel)
        {
            this.output = channel.RemovePaymentInstrument(input);

            return this.output;
        }

        public override void PrepareRequestData()
        {
            this.input = new RemovePaymentInstrumentInput()
            {
                APIContext = new APIContext()
                {
                    TrackingGuid = this.trackingGuid,
                },
                CallerInfo = this.callerInfo,
                PaymentMethodID = this.paymentMethodId,
            };
        }

        public override void PrepareResponseData()
        {
            // don't need to do anything here
        }
    }
}
